package soccerscope.view;

import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * a jump button with place for more graphical components. Used to jump from one
 * Scene to another.
 * 
 * @author benjaboe
 * 
 */
public abstract class AbstractSceneJumper
    extends JPanel
    implements ActionListener {

  /** The Scene player, to set the new scene. */
  private ScenePlayer sPlayer;

  /**
   * Creates a button and add this to a panel. Furthermore the this class
   * becomes ActionListern of the Button.
   * 
   * @param The
   *          Scene player, to set the new scene
   */
  public AbstractSceneJumper(
      ScenePlayer scenePlayer) {

    this.sPlayer = scenePlayer;
    FlowLayout layout = new FlowLayout();
    layout.setAlignment(FlowLayout.LEFT);
    this.setLayout(layout);
    JButton but = new JButton("jump");
    this.add(but);
    but.addActionListener(this);
  }

  /**
   * Jumps to a scene given by the number.
   * 
   * @param sceneNumber
   *          the number of the scene
   */
  public void jumpToScene(int sceneNumber) {

    this.sPlayer.setScene(sceneNumber);
  }

  /**
   * Jumps to a cycle given by the number.
   * 
   * @param cycleNumber
   *          the number of the cycle
   */
  public void jumpToCycle(int cycleNumber) {

    this.sPlayer.skip(cycleNumber);
  }
}
